package com.me.mysqladmin.customize;

import java.util.Properties;

import org.springframework.beans.BeansException;
import org.springframework.beans.factory.config.ConfigurableListableBeanFactory;
import org.springframework.beans.factory.config.PropertyPlaceholderConfigurer;

/**
 * 扩展PropertyPlaceholderConfigurer，增加返回属性值的方法
 * @author dong
 */
public class PropertyConfigCustomization extends PropertyPlaceholderConfigurer {
	private Properties props;
	
	public PropertyConfigCustomization() {
		super();
		this.props = new Properties();
	}

	@Override
	protected void processProperties(
			ConfigurableListableBeanFactory beanFactoryToProcess,
			Properties props) throws BeansException {
		super.processProperties(beanFactoryToProcess, props);
		this.props = props;
	}

	public Properties getProps() {
		return props;
	}
	
	/**
	 * 根据属性名返回对应的属性值
	 * @param name	属性名
	 * @return		属性值
	 */
	public String getProperty(String name) {
		return props.getProperty(name);
	}

	@Override
	public String toString() {
		return "PropertyConfigCustomization [props=" + props + "]";
	}
}
